-- agregar HAVING para que NO recupere lotes que ya no tienen stock 

-- El operador <> es a proposito para que botonee aun los negativos (puede dar la pista de un error...)

CREATE OR REPLACE VIEW public.vstklote AS 
 SELECT artm.idart,
    artm.nrolote,
    artm.fechalote,
    SUM(artm.signo * artm.cant) AS cant
   FROM artm
   WHERE artm.nrolote IS NOT NULL AND artm.modificastock = 'S'
   GROUP BY artm.idart, artm.nrolote, artm.fechalote
   HAVING SUM(artm.signo * artm.cant) <> 0.00;

ALTER TABLE public.vstklote OWNER TO abacouser;


-- =======================================
SELECT aaVersion('431.03','431.02');
-- =======================================